import 'dart:convert';
import 'dart:io';

//格式化旧数据，去掉无关的标点符号
void main(List<String> args) async {
  File file = File(
      "/Users/yaplekde/Development/flutter_projects/mobile-app/lib/l10n/intl_zh.arb");
  final data = await file.readAsString();
  Map<String, dynamic> jsonMap = json.decode(data);

  Map<String, dynamic> resultMap = {};

  for (final item in jsonMap.entries) {
    final key = item.key
        .replaceAll('\'', '')
        .replaceAll(' ', '')
        .replaceAll('&', '')
        .replaceAll('’', '')
        .replaceAll('_/', '')
        .replaceAll('?', '')
        .replaceAll(':', '')
        .replaceAll('.', '')
        .replaceAll('(', '')
        .replaceAll(')', '')
        .replaceAll('-', '')
        .replaceAll('@', '')
        .replaceAll(',', '')
        .replaceAll('/', '_');
    resultMap[key] = item.value;
  }
  final io = file.openWrite();
  io.write(JsonEncoder.withIndent('  ').convert(resultMap));
  await io.flush();
  await io.close();
  print('done.');
  exit(0);
}
